
const http = require('http');
const url = require('url');
const server = http.createServer((request, response) => {
    let data = url.parse(request.url, true);
    let bg = data.query.bg ? data.query.bg : 'plum';
    // 分离出一个页面 实现修改网页颜色
    // `http://127.0.0.1/?bg=xxx;`
    response.end(`<!DOCTYPE html>
                  <html lang="en">
                  <head>
                  <meta charset="UTF-8">
                  <title>Document</title>
                  </head>
                     <body>
        
                     <style>
            body{
                background:${bg};
             }
        </style>
    </body>
    </html>`);
})
server.listen(80, () => {
    console.log('端口正在运行中……')
})

